const _ =require("..")

// 首页接口实现分页
//page 前端提供的
_.router.get('/index',_.ver.Verification, async (req, res, next)=> {
   let params={},pages=0, totalpage=15;
   params.hasOwnProperty("page")?pages=params.page:pages;
   let startPage=pages*totalpage,
   // params=JSON.parse(req.unparams)
     list=await _.mysql.query(_.config.dev.sql.index.index,[startPage,totalpage])
    console.log("startpage",startPage)
     _.redis.Set(req.url, list.data )
   console.log("解密后:")
   res.json({
      status:list.status,
      data:_.utils.public_encrypt(list.data)
   })
   // res.json(await _.mysql.query('select * from shop where uid=?',[id]))    
});


_.router.get('/info',_.ver.Verification, async (req, res, next)=> {
   let id=(JSON.parse(req.unparams)).id,
   list=await _.mysql.query(_.config.dev.sql.index.index,[id])
   _.redis.Set(req.url, list.data )
   console.log("解密后:")
   res.json({
      status:list.status,
      data:_.utils.public_encrypt(list.data)
   })
   // res.json(await _.mysql.query('select * from shop where uid=?',[id]))
     
});
module.exports = _.router;
